%clear;
%load tlDatasets.mat

HOUSE1 = houseBM;
HOUSE2 = houseCM;

dist_rel = cell( length(HOUSE1.sensor_labels)*length(HOUSE1.sensor_labels)+1, length(HOUSE2.sensor_labels)*length(HOUSE2.sensor_labels)+1 );


for a1=1:length(HOUSE1.sensor_labels),
    
    a1_id = HOUSE1.sensor_labels{a1,1};
    
    for a2=1:length(HOUSE1.sensor_labels),
        a2_id = HOUSE1.sensor_labels{a2,1};
        
        a1a2       = relationalProfile(HOUSE1,a1_id,a2_id);
        a1a2_mu    = mean(a1a2);
        a1a2_sigma = var(a1a2);
        
        fprintf('(%d,%d)\n',a1,a2);
        
        for b1=1:length(HOUSE2.sensor_labels),
            
            b1_id = HOUSE2.sensor_labels{b1,1};
            
            for b2=1:length(HOUSE2.sensor_labels),
                
                b2_id = HOUSE2.sensor_labels{b2,1};
                
                b1b2       = relationalProfile(HOUSE2,b1_id,b2_id);
                b1b2_mu    = mean(b1b2);
                b1b2_sigma = var(b1b2);
                
                x = (a1-1)*length(HOUSE1.sensor_labels) + a2;
                y = (b1-1)*length(HOUSE2.sensor_labels) + b2;
                
                dist_rel{x+1,1} = sprintf('(%d,%d)',a1,a2);
                dist_rel{1,y+1} = sprintf('(%d,%d)',b1,b2);
                dist_rel{ x+1 , y+1 } = rel_compare_profiles(a1a2_mu, a1a2_sigma, b1b2_mu, b1b2_sigma);
            end
        end
    end
end


dist_rel_BMCM = dist_rel;

% NOTE: The following is just a duplicate of the above script, to compute the relational matrix for other two houses

%~ 
%~ HOUSE1 = houseAM;
%~ HOUSE2 = houseBM;
%~ 
%~ dist_rel = cell( length(HOUSE1.sensor_labels)*length(HOUSE1.sensor_labels)+1, length(HOUSE2.sensor_labels)*length(HOUSE2.sensor_labels)+1 );
%~ 
%~ 
%~ for a1=1:length(HOUSE1.sensor_labels),
    %~ 
    %~ a1_id = HOUSE1.sensor_labels{a1,1};
    %~ 
    %~ for a2=1:length(HOUSE1.sensor_labels),
        %~ a2_id = HOUSE1.sensor_labels{a2,1};
        %~ 
        %~ a1a2       = relationalProfile(HOUSE1,a1_id,a2_id);
        %~ a1a2_mu    = mean(a1a2);
        %~ a1a2_sigma = var(a1a2);
        %~ 
        %~ fprintf('(%d,%d)\n',a1,a2);
        %~ 
        %~ for b1=1:length(HOUSE2.sensor_labels),
            %~ 
            %~ b1_id = HOUSE2.sensor_labels{b1,1};
            %~ 
            %~ for b2=1:length(HOUSE2.sensor_labels),
                %~ 
                %~ b2_id = HOUSE2.sensor_labels{b2,1};
                %~ 
                %~ b1b2       = relationalProfile(HOUSE2,b1_id,b2_id);
                %~ b1b2_mu    = mean(b1b2);
                %~ b1b2_sigma = var(b1b2);
                %~ 
                %~ x = (a1-1)*length(HOUSE1.sensor_labels) + a2;
                %~ y = (b1-1)*length(HOUSE2.sensor_labels) + b2;
                %~ 
                %~ dist_rel{x+1,1} = sprintf('(%d,%d)',a1,a2);
                %~ dist_rel{1,y+1} = sprintf('(%d,%d)',b1,b2);
                %~ dist_rel{ x+1 , y+1 } = rel_compare_profiles(a1a2_mu, a1a2_sigma, b1b2_mu, b1b2_sigma);
            %~ end
        %~ end
    %~ end
%~ end
%~ 
%~ dist_rel_AMBM = dist_rel;
